package HRMPROJECT.CONTROLLERS;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.swing.table.DefaultTableModel;

import HRMPROJECT.BASEUTILS.Commons;
import HRMPROJECT.MODELS.SearchOfModels;
import HRMPROJECT.MODELS.SearchingEntity;
import HRMPROJECT.MODELS.SecurityContexts;

public class SearchControllers {
    private Connection m_objConnection = null;
    private SecurityContexts m_objSecurity = null;
    private SearchOfModels m_objSearchModel;
    
    public SearchControllers(Connection objConnection, SecurityContexts objSecurity){
        m_objConnection = objConnection;
        m_objSecurity = objSecurity;
        m_objSearchModel = new SearchOfModels(m_objConnection);
    }
    
    /***
     * Nghiệp vụ hiển thị
     * @return
     * @throws SQLException 
     */
    public ResultSet getSearchingInfo(SearchingEntity objSeachInfo) throws SQLException {
        return m_objSearchModel.getElements(objSeachInfo);
    }
    
    /***
     * 
     * @param objSeachInfo
     * @return
     * @throws SQLException
     */
    public DefaultTableModel SearchTableModels(SearchingEntity objSeachInfo) throws SQLException {
        DefaultTableModel objDtm = null;
        try {
            ResultSet objRs = getSearchingInfo(objSeachInfo);
            Commons objComs = new Commons();
            objDtm = new DefaultTableModel();
            objDtm = objComs.getModels(objRs);
        } catch (SQLException e) {
            throw e;
        }
        return objDtm;
    }
}
